<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>navigator</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
        }
    </style>
</head>

<body>

    <script type="text/javascript">
        /* 
        navigator 浏览器相关信息
            userAgent 用于判断浏览器当前环境，需要正则表达式验证  /xx/.test(str) 校验字符串中是否含有xx

            onLine 设备是否处于在线

            cookieEnabled 返回浏览器是否使用cookie
        */

        var browserName = navigator.userAgent.toLowerCase();
        //区分手机端还是PC端
        isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/.test(browserName));

        //判断浏览器
        isFirefox = /firefox/.test(browserName);
        isChrome = /chrome/.test(browserName) && /webkit/.test(browserName) && /mozilla/.test(browserName);
       
        console.log("isMobile", isMobile);
        console.log("isFirefox", isFirefox);
        console.log("isChrome", isChrome);

        console.log(navigator.onLine);
    </script>
</body>

</html>